<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>极客 001 官网案例</title>
  <style>
    .img-box {
      position: relative;
      left: 0;
      top: 0;
      width: 1005px;
      height: 667px;
      margin: 0 auto;
    }

    img {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
    }

    img:nth-child(1) {
      display: none;
      z-index: 1;
    }
  </style>
</head>

<body>
  <div class="img-box">
    <img src="../images/car_blue.png">
    <img src="../images/car_grey.png">
  </div>
  <script>
    const img = document.querySelectorAll('img')
    const box = document.querySelector('.img-box')
    console.log(img, box);

    box.onmousemove = (e) => {
      const offsetX = e.offsetX
      const offsetY = e.offsetY

      img[0].style.clipPath = `circle(20% at ${offsetX}px ${offsetY}px)`
      img[0].style.display = 'inline-block'
    }
  </script>
</body>

</html>